package D1120;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo01 {
    public static void main(String[] args) {
        Collection coll = new ArrayList();
        //增add(Object) 删 remove(Object)  包含contain(Object)    clear()
        //遍历
        String[] arr = {"刘备", "关羽", "张羽"};
        //普通for  传统for
        // for (int i = 0; i < arr.length; i++) ;
        /*增强for
        for (数据类型 变量名:arr)*/
        /*for(String str:arr){
            System.out.println(str);
        }*/
        coll.add("刘备");
        coll.add("张飞");
        coll.add("关羽");
        coll.add("马超");
        //collection遍历
        //传统for失效
        //增强for
        Iterator it = coll.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
        if(it.hasNext()){
            System.out.println(it.next());
        }
        //集合的方法 lamba 方式的forEach()
        coll.forEach((s)->{
            System.out.println(s);
        });
    }
}

